﻿<cfsilent>
	<cfscript>
		
		stringAdvice = getProperty("serviceFactory").getBean("stringAdvice");
		dateTimeAdvice = getProperty("serviceFactory").getBean("datetimeAdvice");
		mathAdvice = getProperty("serviceFactory").getBean("senateMathAdvice");
		
		event.setArg("pageTitle", "打印问卷调查结果");
		
		questionId = event.getArg("QSN");
		
		tagCode = "QSN-" & questionId;
		
		sql = "SELECT title FROM t_questionnaire WHERE qsn_id = :queId "; 
		
		queryObj = new Query( datasource=application.dnsSlave );
		queryObj.addParam( name="queId", value=questionId, cfsqltype="cf_sql_char" );
		
		rs_quesEntity = queryObj.execute( sql=sql ).getResult();
		
		sql = "SELECT 
					 a.quo_id, 
					 a.question, 
					 a.measure, 
					 (SELECT COUNT(*) FROM t_vote_response b WHERE b.quo_id = a.quo_id AND b.answer = 'E') countRes_E, 
					 (SELECT COUNT(*) FROM t_vote_response b WHERE b.quo_id = a.quo_id AND b.answer = 'G') countRes_G, 
					 (SELECT COUNT(*) FROM t_vote_response b WHERE b.quo_id = a.quo_id AND b.answer = 'S') countRes_S, 
					 (SELECT COUNT(*) FROM t_vote_response b WHERE b.quo_id = a.quo_id AND b.answer = 'Y') countRes_Y, 
					 (SELECT COUNT(*) FROM t_vote_response b WHERE b.quo_id = a.quo_id AND b.answer = 'N') countRes_N 
				FROM 
					 t_quota a 
				WHERE 
					 a.qsn_id = :sheetId 
				ORDER BY 
					 a.quo_idx "; 
		
		queryObj = new Query( datasource=application.dnsSlave );
		queryObj.addParam( name="sheetId", value=questionId, cfsqltype="cf_sql_char" );
		
		rs_quota = queryObj.execute( sql=sql ).getResult();
		
	</cfscript>
</cfsilent>

<div class="UIreportTitle">
	<h2><cfoutput>#stringAdvice.XHTMLSafeFormat( rs_quesEntity.title )#</cfoutput></h2>
	<h3>——在线调查问卷结果</h3>
</div>

<cfset row = 0 />
<table class="UIreportTable">
	<tr>
		<td align="center">序</td>
		<td>问题</td>
		<td width="200" align="center">各指标评价情况</td>
		<td align="center">综合</td>
	</tr>
    <cfloop query="rs_quota">
		
		<cfset row++ />
		
		<cfswitch expression="#rs_quota.measure#">
			<cfcase value="L1">
				<!--- 7-Y 8-N --->
				<cfset summarySet = [ rs_quota.countRes_Y, rs_quota.countRes_N ] />
			</cfcase>
			<cfcase value="L3">
				<!--- 6-S 7-Y 8-N --->
				<cfset summarySet = [ rs_quota.countRes_S, rs_quota.countRes_Y, rs_quota.countRes_N ] />
			</cfcase>
			<cfcase value="L4">
				<!--- 4-E 5-G 7-Y 8-N  --->
				<cfset summarySet = [ rs_quota.countRes_E, rs_quota.countRes_G, rs_quota.countRes_Y, rs_quota.countRes_N ] />
			</cfcase>
		</cfswitch>
		<cfset result = numberFormat( 100 * mathAdvice.getSatisfactionDegree( summarySet ), "__.____" ) />
		
		<tr>
			<td align="center"><cfoutput>#row#</cfoutput></td>
			<td align="left"><cfoutput>#stringAdvice.XHTMLSafeFormat( rs_quota.question )#</cfoutput></td>
			<td class="quota">
			<cfswitch expression="#rs_quota.measure#">
				<cfcase value="L1">
					<table>
					<tr>
						<td class="b r">是</td>
						<td class="b ">否</td>
					</tr>
					<!--- 7-Y 8-N --->
					<tr class="valued">
						<td class="r"><cfif rs_quota.countRes_Y><cfoutput>#rs_quota.countRes_Y#</cfoutput><cfelse>-</cfif></td>
						<td><cfif rs_quota.countRes_N><cfoutput>#rs_quota.countRes_N#</cfoutput><cfelse>-</cfif></td>
					</tr>
				</table>
			</cfcase>
			<cfcase value="L3">
				<table>
					<tr>
						<td class="b r">满意</td>
						<td class="b r">基本满意</td>
						<td class="b ">不满意</td>
					</tr>
					<!--- 6-S 7-Y 8-N --->
					<tr class="valued">
						<td class="r"><cfif rs_quota.countRes_S><cfoutput>#rs_quota.countRes_S#</cfoutput><cfelse>-</cfif></td>
						<td class="r"><cfif rs_quota.countRes_Y><cfoutput>#rs_quota.countRes_Y#</cfoutput><cfelse>-</cfif></td>
						<td><cfif rs_quota.countRes_N><cfoutput>#rs_quota.countRes_N#</cfoutput><cfelse>-</cfif></td>
					</tr>
				</table>
			</cfcase>
			<cfcase value="L4">
				<table>
					<tr>
						<td class="b r">优秀</td>
						<td class="b r">较好</td>
						<td class="b r">普通</td>
						<td class="b ">不好</td>
					</tr>
					<!--- 4-E 5-G 7-Y 8-N  --->
					<tr class="valued">
						<td class="r"><cfif rs_quota.countRes_E><cfoutput>#rs_quota.countRes_E#</cfoutput><cfelse>-</cfif></td>
						<td class="r"><cfif rs_quota.countRes_G><cfoutput>#rs_quota.countRes_G#</cfoutput><cfelse>-</cfif></td>
						<td class="r"><cfif rs_quota.countRes_Y><cfoutput>#rs_quota.countRes_Y#</cfoutput><cfelse>-</cfif></td>
						<td><cfif rs_quota.countRes_N><cfoutput>#rs_quota.countRes_N#</cfoutput><cfelse>-</cfif></td>
					</tr>
				</table>
			</cfcase>
		</cfswitch>
		</td>
		<td align="center"><span class="numeric"><cfif result gt 0><cfoutput>#result#</cfoutput> %<cfelse>-</cfif></span></td>
	</tr>
	</cfloop>
</table>

<div class="UIreportFoot">
	<table>
		<tr>
			<td>打印时间 <cfoutput>#dateFormat(now(), "YYYY年MM月DD日")#</cfoutput></td>
			<td align="right"><img src="<cfoutput>#getContextRoot()#</cfoutput>/barcode/Print/<cfoutput>#tagCode#</cfoutput>.png" height="43"/></td>
		</tr>
	</table>
</div>